'''
Created on Sep 29, 2011

@author: f13
'''
import Config, Logger

config = Config.config

class PacketManager():
    def __init__(self):
        logger = Logger.logger.packetMgtLogger
        logger.log(1, "Logger initialized successfully.")
        
    def processPacket(self, packet, deviceManager, communicationManager):
        # For now, this only processes initial heartbeat packets for initialization and initialization packets
        config.packetSet.add(packet.toString())        
        if packet.statusCode == "0001":
            deviceManager.initializeDevice(communicationManager, packet)
        
        elif packet.statusCode == "00FF":
            if packet.deviceID in config.currentDevices and config.currentDevices[packet.deviceID].confirmed == False:
                deviceManager.confirmDevice(packet)
        
        elif packet.statusCode == "0B01":
            deviceManager.checkSignature(packet)